package com.fhz.module_user.data;

import androidx.lifecycle.LiveData;

import com.fhz.core_lib.api.UserApi;
import com.fhz.core_lib.base.BaseResponse;
import com.fhz.core_lib.entity.LoggedInUser;
import com.fhz.core_lib.utils.ApiResponse;
import com.fhz.core_lib.utils.RetrofitFactory;

import java.io.IOException;

/**
 * Class that handles authentication w/ login credentials and retrieves user information.
 */
public class LoginDataSource {

    //登录
    public LiveData<ApiResponse<LoggedInUser>> login(String username, String password) {
            UserApi userApi = RetrofitFactory.getRetrofitFactory().create(UserApi.class);
        LiveData<ApiResponse<LoggedInUser>> login = userApi.login(username, password);
            return login;
    }

    //更新头像
    public LiveData<ApiResponse<LoggedInUser>> updateUser(String nickname ,String headImg){
        UserApi userApi = RetrofitFactory.getRetrofitFactory().create(UserApi.class);
       return userApi.updateUser(nickname,headImg);
    }


    //退出
    public void logout() {
        // TODO: revoke authentication
    }
}